<script setup>
import { ref, onMounted, getCurrentInstance } from 'vue'
import { useRoute } from 'vue-router'
import Loading from '@/components/Loading.vue'

const route = useRoute()
const { proxy } = getCurrentInstance()
const orderId = route.query.orderNo
const loading = ref(true)
const content = ref('')
onMounted(() => paySubmit())
const paySubmit = () => {
  proxy.axios.post('/pay', {
    orderId,
    orderName: 'Vue高仿小米商城',
    amount: 0.01,  // 单位元
    payType: 1   // 1支付宝，2微信
  }).then(res => {
    content.value = res.content
    setTimeout(() => {
      // 将页面里的第一个表单提交
      document.forms[0].submit()
    }, 100)
  })
}
</script>

<template>
  <div class="ali-pay">
    <loading v-if="loading"></loading>
    <!-- <div class="form" v-html="content"></div> -->
  </div>
</template>

<style lang="scss"></style>